#!/usr/bin/python3
# -*- coding:utf-8 -*-
""""
@Author: 李吉凯
@Email: lijk34925@hundsun.com
@Time: 2022/5/25 16:48
@File: page.py
"""
import re

from qturboframe.public_ui.h_ui.page import Page as HuiPage

from BladeFerm.Lib.Common import logger
from BladeFerm.hui12_common.function import get_params


class Page(HuiPage):
    # def __init__(self, element_para, father=None, timeout=5):
    #     logger.info(f'element_para: {element_para}')
    #     super().__init__(element_para, father=father, timeout=timeout)
    #     element_by, element_value, assist = get_params(element_para)
    #     self._element = father.find_element_by_attribute(
    #         element_by, element_value, assist, timeout)
    #     self.locator_by = element_by
    #     self.locator = element_value
    #     logger.info(f'element: {self._element}')


    def get_rows_in_page(self):
        '''
        获取表格页显示的行数

        :Return:
            返回表格页显示的行数

        :Example:
         - 例: page.get_rows_in_page()
        '''
        rows_div = self._element.exist(
            'css selector', 'span.h-page-total',
            timeout=self.timeout)
        if rows_div:
            rows_text = rows_div.text
            rows = int(re.search(r'\d+', rows_text).group())
            return rows
        else:
            return 0